package goleetcode

type Employee struct {
	Id           int
	Importance   int
	Subordinates []int
}

func getImportance(employees []*Employee, id int) int {
    mp := map[int]*Employee{}
	for _, e := range employees {
		mp[e.Id] = e
	}
	total := 0
	var dfs func(int)

	dfs = func(id int) {
		e := mp[id]
		total += e.Importance
		for _, sub := range e.Subordinates {
			dfs(sub)
		}
	}

	dfs(id)
	return total
}